<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.11</title>
</head>

<body>
<?php
	if(isset($_POST['giobd']) && isset($_POST['giokt']))
	{
		$giobd=$_POST['giobd'];
		$giokt=$_POST['giokt'];
		//Gio co hop le
		if($giobd>=10 && $giobd<=24 && $giokt>=10 && $giokt<=24)
		{
			if($giobd<$giokt){
			//TH1: giobd và giokt chua qua 17h
				if($giobd<17 && $giokt<17){
					$thanhtoan=($giokt-$giobd)*20000;
				}
			//TH2: giobd và giokt qua 17h
				if($giobd>=17 && $giokt>=17){
					$thanhtoan=($giokt-$giobd)*45000;
				}
			//TH2: giobd chua qua 17h và giokt qua 17h
				if($giobd<17 && $giokt>=17){
					$gia1=(17-$giobd)*20000;
					$gia2=($giokt-17)*45000;
					$thanhtoan=($gia1+$gia2);
				}
			}
			else
				$thongbao="Nhập giờ không hợp lệ";
		}
		else
			$thongbao="Đang giờ nghỉ";
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_11.php">
  <table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="3" bgcolor="#006699" style="text-align: center; font-style: italic; font-weight: bold; color: #FFF;">TÍNH TIỀN KARAOKE</td>
    </tr>
    <tr bgcolor="#00CCFF">
      <td>Giờ bắt đầu:</td>
      <td><input name="giobd" type="text" id="giobd" value="<?php echo $_POST['giobd'];?>" /></td>
      <td>(h)</td>
    </tr>
    <tr bgcolor="#00CCFF">
      <td>Giờ kết thúc:</td>
      <td style="color: #FFC"><input name="giokt" type="text" id="giokt" value="<?php echo $_POST['giokt'];?>" readonly="readonly" /></td>
      <td>(h)</td>
    </tr>
    <tr bgcolor="#00CCFF">
      <td>Tiền thanh toán:</td>
      <td><input name="thanhtoan" type="text" id="thanhtoan" style="background-color:#FFC" value="<?php echo $thanhtoan;?>" readonly="readonly" /></td>
      <td>(VNĐ)</td>
    </tr>
    <tr bgcolor="#00CCFF" style="text-align: center">
      <td colspan="3"><input type="submit" name="submit" id="submit" value="Tính tiền" /></td>
    </tr>
  </table>
</form>
<table width="350" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td style="text-align: center; color:#F00"><label><?php echo $thongbao;?></label></td>
  </tr>
</table>
</body>
</html>